package com.xunyin.modules.store.service.mapper;

import com.xunyin.common.mapper.CoreMapper;
import com.xunyin.modules.store.domain.TStore;
import com.xunyin.modules.store.vo.TStoreVo;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * @Author xunyinyunshang  <3594419785@qq.com>
 * @date 2022-09-16
 */
@Repository
public interface TStoreMapper extends CoreMapper<TStore> {

    @Select("SELECT st.id as id,st.id as storeId,st.main_id as mainId,st.name,st.address,st.phone, " +
            " st.longitude,st.latitude,st.business_id as businessId,st.business_time as businessTime,st.images,  " +
            " st.remark,st.province_code as provinceCode,st.city_code as cityCode,st.county_code as countyCode," +
            " st.status" +
            "  FROM t_store st " +
            " WHERE st.city_code = #{cityCode} AND st.status = 1 and st.is_del=0 and st.main_id = #{mainId} ")
    @Results(
            @Result(
                    property = "storeRoomList", column = "storeId",
                    javaType = List.class,
                    many = @Many(select = "com.xunyin.modules.storeroom.service.mapper.TStoreRoomMapper.getStoreRooms")
            )
    )
    List<TStoreVo> getStoreInfo(@Param("cityCode") String cityCode, @Param("mainId") Integer mainId);
}
